<?php
/**
 * Created by PhpStorm.
 * User: 24369
 * Date: 2021/6/26
 * Time: 9:05
 */
namespace app\admin\model;

use think\Model;
use think\model\concern\SoftDelete;

class Order extends Model
{
    use SoftDelete;
    protected $deleteTime='delete_time';
    public function searchCidAttr($q,$v){
        if (isset($v)&&$v!='')      $q->where('o.status','=',$v);
    }
    public function searchKeywordsAttr($q,$v){
        if (isset($v)&&$v!='')      $q->where('pay_sn','like',"%{$v}%");
    }
    public static function getOrderList($where,$keywords)
    {
        $list=Order::alias('o')
            ->field('o.id,u.uname,o.price,os.order_status,o.addtime,o.remark')
            ->join('user u','u.id=o.uid')
            ->join('order_status os','o.status=os.status_id')
            ->withSearch(array_keys($where),$where)
            ->paginate([
            'list_rows'=>5,
            'query'=>$where
        ]);
        return  $list;
    }
}